package com.imooc.coupon.advice;

import com.imooc.coupon.exception.CouponException;
import com.imooc.coupon.vo.CommonResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;


/**
 * 全局异常处理
 *
 */
@RestControllerAdvice
public class GlobalExceptionAdvice {
    @ExceptionHandler(value = CouponException.class)
    public CommonResponse<String> handlerCouponException(HttpServletRequest resquest, CouponException ex){
        CommonResponse response = new CommonResponse( -1 ,"buss error");
        response.setData(ex.getMessage());

        return response;
    }
}
